﻿using HandyControl.Controls;
using HandyControl.Data;
using QModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QServices.Services
{
    public partial class UserService:QMainService
    {
        public bool Login(User info)
        {
            if (info == null) return false;
            if (string.IsNullOrWhiteSpace(info.Account))
            {
               return false;
            }
            if (string.IsNullOrWhiteSpace(info.Password)) return false;
            using var db=CreateDbContext();
            string password_md5 = MD5Helper.Encrypt(info.Password, Encoding.UTF8, true);
            var user=db.Set<User>().FirstOrDefault(x=>x.Account == info.Account && x.Password==password_md5);
            if (user == null) return false;
            return true;

        }
    }
}
